﻿using System;
using System.IO;
using LogLibrary.Entity;
using SilverPOP.Data.Process.Helpers.LoggerHelper;

namespace Utilities
{
    public class FileWriter
    {
        public static void WriteToFile(String fileNameWithName, String message)
        {
            File.AppendAllText(fileNameWithName, message + Environment.NewLine);

            var logServiceInformation = new LogServiceInformation
            {
                ProjectId = LoggerHelper.ProjectId,
                TaskListId =LoggerHelper.TaskListId , 
                CampaignId =LoggerHelper.CampaignId,
                CustomErrorMessage = message,
                StackTrace = Environment.StackTrace,
            };

            var logger = new LogLibrary.Logger(typeof(FileWriter), fileNameWithName);
            logger.Log(LogType.INFO, logServiceInformation);
        }
    }
}
